"""example of how to cluster a graph based on edges curvatures"""
import os
import pickle

import networkx as nx
import matplotlib.pyplot as plt

from geometric_clustering import io
from pygenstability.plotting import plot_scan

graph_name = "jaccard"

graph = nx.read_gpickle(os.path.join("data", "hox_gene_expression_" + graph_name + ".gpickle"))
graph = nx.convert_node_labels_to_integers(graph)

os.chdir(graph_name)

times, kappas = io.load_curvature(filename="curvature.pkl")
for method in ["geometric_modularity", "markovstab"]:
    cluster_results = pickle.load(open(method + "_results.pkl", "rb"))
    del cluster_results["stability"]  # to not plot stability
    plt.figure(figsize=(5, 3))
    plot_scan(cluster_results, figure_name=method + ".pdf", use_plotly=False)

plt.show()
